package com.store.orm.execute;

import com.store.orm.mysql.MySQLUtil;
import com.store.orm.mysql.crud.Delete;
import com.store.orm.mysql.crud.Insert;
import com.store.orm.mysql.crud.Select;
import com.store.orm.mysql.crud.Update;
import com.store.orm.mysql.crud.impl.*;
import com.store.orm.mysql.reflection.DeleteProxy;
import com.store.orm.mysql.reflection.InsertProxy;
import com.store.orm.mysql.reflection.UpdateProxy;

/**
 * @author 宫静雨
 * @version 1.0
 */
public class MySQLFactory {
    private MySQLUtil mySQLUtil;

    public MySQLFactory(MySQLUtil mySQLUtil) {
        this.mySQLUtil = mySQLUtil;
    }

    public Insert insert() {
        return new InsertProxy(new MySQLInsert(mySQLUtil)).proxy();
    }

    public Update update() {
        return new UpdateProxy(new MySQLUpdate(mySQLUtil)).proxy();
    }

    public Delete delete() {
        return new DeleteProxy(new MySQLDelete(mySQLUtil)).proxy();
    }

    public Select select() {
        return new MySQLSelect(mySQLUtil);
    }

    public <T> PageSelect<T> pageSelect(Integer pageNum, Integer pageSize, Class<T> cls) {
        return new PageSelect<>(mySQLUtil, pageNum, pageSize, cls);
    }

    public MultiSelect multiSelect() {
        return new MultiSelect(mySQLUtil);
    }

    public GroupSelect groupSelect() {
        return new GroupSelect(mySQLUtil);
    }

    public MySQLUtil getMySQLUtil() {
        return mySQLUtil;
    }
}
